﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OneSystems.Data.Entities;

namespace OneSystems.BusinessLogic
{
    public sealed class DebtorLogic
    {
        private DebtorLogic() { }

        public static Debtor GetUser()
        {
            return Debtor.GetAll().First();
        }
        public static Debtor GetUser(int debtorID)
        {
            return Debtor.GetOne(debtorID);
        }

        public static Debtor SaveDebtor( int debtorID, string surname, string givenName, string othernames, decimal pledgeAmount, DateTime birthdate)
        {
            Debtor debtor = new Debtor();
            if (debtorID > 0)
            {
                debtor = Debtor.GetOne(debtorID);
            }

            debtor.Surname = surname;
            debtor.GivenName = givenName;
            debtor.OtherNames = othernames;
            debtor.BirthDate = birthdate;
            debtor.PledgeAmount = pledgeAmount;
            debtor.Save();
            return debtor;
        }
    }
}
